<!doctype html>
<html>

<head>
	<title></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<link rel="stylesheet" href="../res/css/weui.css" />
	<link rel="stylesheet" href="../res/css/weuix.css" />
	<link rel="stylesheet" href="../res/css/mp_common.css" />
	<link rel="stylesheet" href="../res/css/common.css" />
	<link rel="stylesheet" href="../res/css/verification.css" />	<!-- 核销码 -->
	<script src="../res/js/zepto.min.js"></script>
	<script src="../res/js/zepto.weui.js"></script>
	<script src="../res/js/mp_common.js?v=1"></script>
	<script src="../res/js/qrcode.min.js"></script>
	<script src="../res/js/common.js"></script>
	<script src="../res/js/verification.js"></script>	<!-- 核销码 -->
	<script src="../res/js/JsBarcode.all.min.js" type="text/javascript"></script>
</head>
<style>
	.weui-cells {
		font-size: 14px;
	}

	.weui-cell {
		margin-bottom: 0px;
	}

	#div_dd_ls_info span {
		float: right;
	}

	.line {
		display: flex;
		font-size: 63px;
		height: 20px;
		line-height: 9px;
		color: #F9F8FE;
	}

	.line div {
		height: 18px;
		width: 18px;
		background: #F9F8FE;
		border-radius: 18px;
		margin: 0 1%;
		position: absolute;
	}

	.line div:first-child {
		left: -10px;
	}

	.line div:last-child {
		right: -10px;
	}

	.fixed-top {
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 100;
	}

	.show_drug {
		height: 60px;
		margin-top: 10px;
	}

	.drug_img {
		width: 60px;
		height: 60px;
		float: left;
		border-radius: 10px;
	}

	.show_drug>div {
		padding: 0 10px;
		color: #8a8a8a;
		float: left;
		height: 60px;
		width: 75%;
		line-height: 30px;
		position: relative;
	}

	.drug_price {
		position: absolute;
		top: 12px;
		right: 20px;
		color: #FA6464;
	}

	.show_drug {
		height: 60px;
		margin-top: 10px;
	}

	.drug_img {
		width: 60px;
		height: 60px;
		float: left;
		border-radius: 10px;
	}

	.show_drug>div {
		padding: 0 10px;
		color: #8a8a8a;
		float: left;
		height: 60px;
		width: 75%;
		line-height: 30px;
		position: relative;
	}

	.drug_price {
		position: absolute;
		top: 12px;
		right: 20px;
		color: #FA6464;
	}

	.titleDiv {
		margin-top: 40px;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
	}

	.titleDiv div {
		padding: 15px 20px;
	}

	#p_status {
		font-size: 20px;
		color: #353535;
		font-weight: bold;
		font-family: PingFang-SC-Medium;
	}

	#goSeeOrder {
		color: #4187F7;
		line-height: 30px;
	}

	#callShop {
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		padding: 10px 0;
		flex-wrap: wrap;
	}

	#p_pat_name {
		font-size: 15px;
		color: #353535;
		font-weight: bold;
	}

	#p_pat_address {
		font-size: 15px;
		color: #353535;
		font-weight: bold;
	}

	#takePhoto {
		display: flex;
		margin-right: 30px;
		flex-wrap: wrap;
		width: 20%;
		justify-content: center;
	}

	.drug_price {
		position: absolute;
		top: 5px;
		right: 10px;
		color: #000;
		font-size: 19px;
	}

	.weui-cells {
		font-size: 15px;
	}

	.hisText {
		width: 90%;
		height: 50px;
		background-color: #C9C9C9;
		margin: 5px 5%;
		text-align: center;
		margin-top: 0px;
		border-radius: 5px;
		line-height: 50px;
	}
</style>

<body ontouchstart>
	<div class="fixed-top" style="padding: 7px 2px; background-color: #ffffff; font-size: 18px; ">
		<div class="weui-flex__item">
			<div class="placeholder">
				<span class="icon icon-109" style=" margin-left: 8px;" onclick="ToPage()">
				</span><span style="padding-left: 29%;">自取订单确认</span>
			</div>
		</div>
	</div>
	<div class="titleDiv">
		<div id="p_status">待自提</div>
		<div id="goSeeOrder">查看原始处方 ></div>
	</div>
	<div id="div_dd_info">
		<!-- <div class="weui-cell" style="display:block; text-align:center;">
			<img id="barcode" type="hidden" style="width:70%; height:80px;" /><br />

			<div id="qrcode" style="margin:0 auto;    width: 25%;"></div>
			<input id="hid_rx_code" value="s_rx_dtl.htm?data=ax7rV42DgE7" type="hidden" />
		</div> -->
		<div id="callShop">
			<div style="display: flex;">
				<img src="../res/images/link_people_icon.png" alt=""
					style="width: 35px;height: 35px;padding: 20px 0px;padding-left: 20px;">
				<div>
					<div id="p_pat_name" style="padding: 0px 5px;margin-top:10px">收货人</div>
					<div id="p_pat_address" style="padding: 0px 5px;color: #868686;font-weight: 500;"></div>
				</div>
			</div>
			<a id="takePhoto" href="tel:400-0000-688">
				<img src="../res/images/link-phone.png" alt="" style="width: 40px;height: 40px;">
				<div style="width: 100%;text-align: center;color: #4187F7;font-size: 15px;">联系商家</div>
			</a>
		</div>

		<div id="verificationView">
			<div id="verificationCode">
				核销码: <span id="codeContent"></span>
			</div>
		</div>
		
		<div class="weui-cells">
			<div class="weui-cell">
				<div class="weui-cell__bd" id="div_dd_dtl">
				</div>
			</div>
		</div>
		<div class="weui-cells">
			<div class="weui-cell">
				<div class="weui-cell__bd" id="div_dd_ls_info">
					<p style="font-size: 12px;padding: 5px;border-bottom: 1px solid #F2F2F2;">订单信息</p>
					<p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
						订单编号：<span style="margin-right: 10px;">1000880</span></p>
					<p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
						下单时间：<span style="margin-right: 10px;">1000880</span></p>
				</div>
			</div>
		</div>
		<!-- <div class="weui-cells">
			<div class="weui-cell" style="margin-bottom: 10px;">
				<div class="weui-cell__bd" id="div_dd_ls_info">
					<p style="font-size: 12px;">订单编号：<span style="color:Blue;">[复制]</span></p>
					<p style="font-size: 12px;">下单时间：</p> -->
		<!--<p style="font-size: 12px;">支付状态：未支付</p>-->
		<!-- <p style="font-size: 12px;">支付时间：</p>
					<p style="font-size: 12px;">支付方式：</p>
					<p style="font-size: 12px;">取药方式：</p>
				</div>
			</div>
		</div> -->
		<div style="color: #C9C9C9;text-align: center;padding: 60px 0 !important">如有疑问，可联系客服</div>
		<div class="weui-cells">
			<div class="weui-cell"
				style="margin:0px !important;margin-bottom: 10px;position: fixed;bottom: 0px;width: 95%;overflow: hidden;">
				<div class="weui-cell__bd">
					<p style="font-size: 13px;"></p>
				</div>
				<div class="weui-cell__ft" style="font-size: 13px; margin-left:10px;" id="div_act_btn2"><a
						href="javascript:;" class="weui-btn weui-btn_mini  bg-orange" style="width:100px; color:#fff;"
						onclick="Pay_indent();">继续支付</a></div>
				<div class="weui-cell__ft" style="font-size: 13px; margin-left:10px;" id="div_act_btn"><a
						href="javascript:;" class="weui-btn weui-btn_mini  bg-orange" style="width:100px; color:#fff;"
						onclick="confirm_indent();">取货成功</a></div>
			</div>
		</div>
	</div>

</body>

</html>
<script type="text/javascript">
	var prescription_id = "";
	var indent_state = "0";
	var user_id = getQst("user_id").trim();
	var openid = getQst("openid").trim();
	var rstData;
	var orderDetail = {};
	var loc_x, loc_y;
	var inside = getQst('inside');
	if(!inside || inside === 'false'){
		inside = false
	}else{
		inside = true
	}

	$(function () {
		prescription_id = getQst("prescription_id").trim();
		//条形码
		// JsBarcode("#barcode", prescription_id, {
		// 	format: "CODE39",
		// 	width: 3,
		// 	height: 60,
		// 	displayValue: false,
		// 	font: "arial",
		// 	lineColor: "#000",

		// });
		//二维码
		// var smUrl = window.location.host + "http://zz.nxk520.com/netcflz/shop_dtl3.htm?prescription_id=" +
		// 	prescription_id;
		// $("#hid_rx_code").val(smUrl);
		// getQCCode("qrcode", document.getElementById("hid_rx_code"), 100, 100);

		let params = {
			"order_num": prescription_id
		}
		newAjaxPost("/h5/thirdParty/orderDetail", params, getDDData);
		// -------------------
	});

	//获取数据
	function getDDData(Data) {
		var sum_price = 0,
			str_dd_dtl_html = "";
		rstData = Data;
		orderDetail = Data.data;
		loc_x = Data.data.loc_x;
		loc_y = Data.data.loc_y;
		if (rstData.code == 1) {
			newAjaxPost("/h5/userInfo/userInfo", {}, doOk);
			$("#takePhoto").attr("href", `tel:${rstData.data.store_phone}`)

			function doOk(res) {
				var userInfo = res.data;
				if (userInfo.userImg == undefined || userInfo.userImg == null) {
					$("#img_user_head").attr("src", '../res/images/head_icon.png');
				} else {
					$("#img_user_head").attr("src", userInfo.userImg);
				}
				// $("#p_user_name").html("用户："+(isSpace(rstData.data.patient_name)?"未设置":rstData.data.patient_name));
				$("#p_user_name").html("用户：" + (isSpace(userInfo.trueName) ? "未设置" : userInfo.trueName));
				$("#p_user_mark").html("手机号：" + userInfo.mobile);
			}
			if (rstData.data.indent_state == STwaitPay) {
				//10:未付款(待付款)
				$("#p_status").html("未付款");
			} else if (rstData.data.indent_state == STwaitTake) {
				//35:待自提
				$("#p_status").html("待自提");
				$("#p_pat_address").hide()
			} else if (rstData.data.indent_state == STwaitSend) {
				//20:待发货
				$("#p_status").html("待发货");
			} else if (rstData.data.indent_state == STsended) {
				//30:已发货(待收货)
				$("#p_status").html("待收货");
			} else if (rstData.data.indent_state == STcancel) {
				//订单状态：0:已取消
				$("#p_status").html("已取消");
			} else if (rstData.data.indent_state == STfinished) {
				//40:已收货(已完成)
				$("#p_status").html("已完成");
			}
			if (isSpace(rstData.data.pat_name)) {
				rstData.data.pat_name = '未设置'
			}
			// $("#p_pat_name").html(rstData.data.pat_name + " " + rstData.data.pat_photo);
			// if (isSpace(rstData.data.address_detl)) {
			// 	$("#p_pat_address").html("收货地址：未设置");
			// } else {
			// 	$("#p_pat_address").html(rstData.data.address_name + " " + rstData.data.address_detl);
			// }
			if (rstData.data.take_type == 1) {
				$("#takePhoto").hide()
				$("#p_pat_name").html(rstData.data.pat_name + " " + rstData.data.pat_photo);
				if (isSpace(rstData.data.address_detl)) {
					$("#p_pat_address").html("收货地址：未设置");
				} else {
					$("#p_pat_address").html(rstData.data.address_name + " " + rstData.data.address_detl);
				}
			} else {
				$("#pay_Btn").css('display', 'none');
				$("#p_pat_name").html(rstData.data.pat_name + " " + rstData.data.pat_photo);
				if (isSpace(rstData.data.address_detl)) {
					$("#p_pat_address").html("收货地址：未设置");
				} else {
					$("#p_pat_address").html(rstData.data.address_name + " " + rstData.data.address_detl);
				}
			}
			$("#txt_logistics_name").val(rstData.data.logistics_name);
			$("#txt_logistics_no").val(rstData.data.logistics_no);
			$("#txt_logistics_cost").val(rstData.data.logistics_cost);
			$("#div_kd_info").hide();
			if (!isSpace(rstData.data.logistics_name)) {
				$("#div_kd_tx").hide();
				$("#div_kd_info").show();
				var kd_info_html = "";
				kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">您的订单已由" + rstData.data.logistics_name +
					"承运</p>";
				//复制
				kd_info_html = kd_info_html + "<p style=\"font-size: 12px;  display: inline-block;\">运单号：" + rstData.data
					.logistics_no + "</p>";
				kd_info_html = kd_info_html + "<input class=\"courier-text\" value=\"" + rstData.data.logistics_no +
					"\" type=\"hidden\" />";
				kd_info_html = kd_info_html +
					"<a href=\"javascript:;\" style=\"color: Blue;  color: #2b73cc;font-size: 13px;margin-left: 5px;\" class=\"courier-btn\">[复制]</a>";

				kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">发货时间：" + rstData.data.send_time + "</p>";
				$("#div_kd_info_msg").html(kd_info_html);
			}
			//通过处方详情查药品信息
			newAjaxPost("/h5/myInterrogation/getPrescriptioninfo", {
				"prescriptionNo": rstData.data.rp_id
			}, infoOk);

			function infoOk(res) {
				//跳转到查看原始处方页面
				$("#goSeeOrder").click(() => {
					actToPage('inquiry_go_order.htm?order_id=' + res.data.prescriptionNo + '&id=' + res.data.id +
						'&is_order=1');
				})

				if (res.code == 1) {
					console.log(res.data);
					str_dd_dtl_html +=
						'<div style="padding: 10px 10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;font-size:15px">';
					str_dd_dtl_html += '<span style="margin-right:20px;">' + orderDetail.group_name + '</span>';
					str_dd_dtl_html +=
						`<span style="margin-right:20px;color: #4187F7;" onclick="actToPage('user_dtl_map.htm?loc_x=${loc_x}&loc_y=${loc_y}')">查看地图</span>`;
					str_dd_dtl_html += '</div>';
					//西药列表
					if (res.data.westernMedicineResqList != null) {
						for (var i = 0; i < res.data.westernMedicineResqList.length; i++) {
							str_dd_dtl_html += '<div class="show_drug">';
							str_dd_dtl_html += '<img src="' + (isSpace(res.data.westernMedicineResqList[i].drugImg) ?
									"../res/images/medisen1.jpg" : res.data.westernMedicineResqList[i].drugImg) +
								'" class="drug_img">';
							str_dd_dtl_html += '<div class="drug_num">';
							str_dd_dtl_html += '<div class="drug_name">' + res.data.westernMedicineResqList[i]
								.drugName + '</div>';
							str_dd_dtl_html +=
								'<div style="font-size:24rpx;display:flex;justify-content: space-between;">';
							str_dd_dtl_html += '<span>' + res.data.westernMedicineResqList[i].detailsNum + res.data
								.westernMedicineResqList[i].drugPackagingUnit + '</span>';
							str_dd_dtl_html += '<div style="margin-right:10px">x' + res.data.westernMedicineResqList[i]
								.detailsConsumption + '</div>';
							str_dd_dtl_html += '</div>';
							str_dd_dtl_html += '<div class="drug_price">￥' + res.data.westernMedicineResqList[i]
								.drugPrice + '</div>';
							str_dd_dtl_html += '</div>';
							str_dd_dtl_html += '</div>';
						}
					}
					//中药列表 
					else {
						if (res.data.chineseMedicineResqList != null) {
							for (var i = 0; i < res.data.chineseMedicineResqList.length; i++) {
								str_dd_dtl_html += '<div class="show_drug">';
								str_dd_dtl_html += '<img src="' + (isSpace(res.data.chineseMedicineResqList[i].drugImg) ?
										"../res/images/medisen1.jpg" : res.data.chineseMedicineResqList[i].drugImg) +
									'" class="drug_img">';
								str_dd_dtl_html += '<div class="drug_num">';
								str_dd_dtl_html += '<div class="drug_name">' + res.data.chineseMedicineResqList[i]
									.drugName + '</div>';
								str_dd_dtl_html +=
									'<div style="font-size:24rpx;display:flex;justify-content: space-between;">';
								str_dd_dtl_html += '<span>' + res.data.chineseMedicineResqList[i].detailsConsumption +
									res.data.chineseMedicineResqList[i].detailsConsumptionUnit + '</span>';
								str_dd_dtl_html += '<div style="margin-right:10px">x' + res.data.chineseMedicineResqList[i]
									.detailsConsumption + '</div>';
								str_dd_dtl_html += '</div>';
								str_dd_dtl_html += '<div class="drug_price">￥' + res.data.chineseMedicineResqList[i]
									.drugPrice + '</div>';
								str_dd_dtl_html += '</div>';
								str_dd_dtl_html += '</div>';
							}
						} else {}
					}
					str_dd_dtl_html += '<div style="padding:10px;border-bottom: 1px solid #F2F2F2;">';
					str_dd_dtl_html +=
						`<span style="margin-left:75%;color: #4187F7;" onclick="actToPage('inquiry_go_med.htm?id=' + ${res.data.id})">用药详情></span>`;
					str_dd_dtl_html += '</div>';
					str_dd_dtl_html +=
						`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>商品总金额</div><div>￥${orderDetail.indent_total}</div></div>`
					if (isHis && inside) {
						str_dd_dtl_html +=
							`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>代煎费</div><div>￥0</div></div>`
						str_dd_dtl_html +=
							`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>医保统筹/公医结账</div><div>￥0</div></div>`
					}
					str_dd_dtl_html += '<div style="padding:10px;display:flex;justify-content:right;">';
					str_dd_dtl_html +=
						`<span style="font-size: 15px;font-weight: bold;">应付总金额: ￥${orderDetail.indent_total}</span>`;
					str_dd_dtl_html += '</div>';
				} else {
					msgInfo(res.msg)
				}
			}


			$("#div_dd_dtl").html(str_dd_dtl_html);

			var str_dd_ls_info = "";
			str_dd_ls_info += `<p style="font-size: 12px;padding: 5px;border-bottom: 1px solid #F2F2F2;">订单信息</p>
            <p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
                        订单编号：<span style="margin-right: 10px;">${rstData.data.order_sn }</span></p>
            <p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
                        下单时间：<span style="margin-right: 10px;">${rstData.data.create_time}</span></p>
			<p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
                        支付时间：<span style="margin-right: 10px;">${rstData.data.payment_time}</span></p>`

			$("#div_dd_ls_info").html(str_dd_ls_info);

			$("#div_sum_price").html("￥" + rstData.data.indent_total);
			$("#div_yf_price").html("￥" + rstData.data.logistics_cost);
			indent_state = rstData.data.indent_state;
			pay_status = rstData.data.pay_status;
			if (pay_status == 1) {
				// 已支付
				// $('#div_act_btn2').html("<a href=\"javascript:;\" class=\"weui-btn weui-btn_mini  bg-gray\" style=\"width:100px; color:#CCC;\" >已支付</a>");
				$('#div_act_btn2').html(
					"<a href=\"javascript:;\" class=\"weui-btn weui-btn_mini  bg-red\" style=\"width:100px; color:#FFF;\" onclick=\"Cancel_indent()\">退款</a>"
				);
			} else {
				//未支付，不操作
				$("#div_act_btn a").css("pointer-events", "none");
				$('#div_act_btn a').css("background-color", "gray");
			}

			if (rstData.data.indent_state == 20) {
				//20:待发货
			} else if (rstData.data.indent_state == 30) {
				//30:已发货(待收货)
				$("#div_act_btn2").html(
					"<a href=\"javascript:;\" class=\"weui-btn weui-btn_mini  bg-gray\" style=\"width:100px; color:#CCC;\">退款</a>"
				);
			} else if (rstData.data.indent_state == 0) {
				//订单状态：0:已取消
				$("#div_act_btn2").html(
					"<a href=\"javascript:;\" class=\"weui-btn weui-btn_mini  bg-gray\" style=\"width:100px; color:#CCC;\">退款</a>"
				);
			}

			setVerificationCode(orderDetail.writeOffCode)
		} else {
			$("#p_status").html("无该订单信息");
			$("#div_dd_info").hide();
		}
	}

	//确认收货
	function confirm_indent(rstData) {
		$.modal({
			title: "确认取货成功吗？",
			buttons: [{
					text: "确认",
					onClick: function () {
						var pJson = {
							"order_num": prescription_id,
							"type": 2
						};
						newAjaxPost("/h5/thirdParty/saveOrder", pJson, function (rstData) {
							console.log(rstData)
							if (rstData.code == 1) {
								showJSZ("收货成功");
								actToPage('user_dtl4.htm?prescription_id=' + prescription_id +
									'&user_id=' + user_id);
							} else {
								showJSZ(rstData.msg);
							}
						});

					}
				},
				{
					text: "取消",
					className: "default",
					onClick: function () {

					}
				},
			]
		});
	}

	//跳转支付页面
	function Pay_indent() {
		//2020.04.08----------
		if (!isSpace(openid)) {
			actToPage('user_dtl5.htm?prescription_id=' + prescription_id + '&openid=' + openid);
		} else {
			actToPage('user_dtl5.htm?prescription_id=' + prescription_id + '&user_id=' + user_id);
		}
		//-------------------
	}

	//退款
	function Cancel_indent() {

		$.alert("退款请联系客服，客服热线：\r\n020-32640557", function () {
			return;
		});
	}

	function Cancel_indentOK(rstData) {
		console.log(rstData)
		var msg = rstData.msg;
		var str = msg.charAt(9);
		//退款成功，回到订单列表
		if (str == 1) {
			showJSZ("退款成功!，三秒后回到我的订单")
			setTimeout(function () {
				ToPage();
			}, 2000)
		}
	}

	//返回列表
	function ToPage() {
		if (!isSpace(openid)) {
			actToPage('user_list.htm?openid=' + openid);
		}
		if (!isSpace(user_id)) {
			actToPage('user_list.htm?user_id=' + user_id);
		}
	}
</script>